package com.chub.study.modules.entity;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chub.study.modules.annotation.DictName;
import com.chub.study.modules.annotation.DictTranslate;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 学生信息表
 * </p>
 *
 * @author chub
 * @since 2021-08-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
// 常用属性：
//  fluent：如果设置为 true，生成的 getter 方法会移除 get 前缀，setter 方法移除 set 前缀。
//  chain：如果设置为 true，生成的 setter 方法会返回当前对象，支持方法链调用。
//  prefix：为生成的 getter 和 setter 方法添加指定前缀。
@TableName("t_stud_info")
@ApiModel(value="TStudInfo", description="学生信息表")
public class TStudInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "学生编号")
    @TableId("XSBH")
    private String xsbh;

    @ApiModelProperty(value = "学生姓名")
    @TableField("XSXM")
    private String xsxm;

    @ApiModelProperty(value = "学生年龄")
    @TableField("XSNL")
    private Integer xsnl;

    @ApiModelProperty(value = "学生性别 0:女 1:男")
    @TableField("XSXB")
    private String xsxb;

    @ApiModelProperty(value = "补助金额")
    @TableField("BZJE")
    private BigDecimal bzje;

    @ApiModelProperty(value = "学生班级编号")
    @TableField("BJBH")
    private String bjbh;

    @ApiModelProperty(value = "学生出生日期")
    @TableField("CSRI")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATE_PATTERN)
    // @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)  // 返回前端日期格式不对，这个不行
    // @JsonSerialize(using = LocalDateSerializer.class)             // 返回前端日期格式不对，这个不行
    // @JsonDeserialize(using = LocalDateDeserializer.class)         // 返回前端日期格式不对，这个不行
    private LocalDate csri;

    @ApiModelProperty(value = "学生手机号码")
    @TableField("PHONE")
    private String phone;

    @ApiModelProperty(value = "家庭地址")
    @TableField("HOMEADDR")
    private String homeAddr;

    @ApiModelProperty(value = "创建时间")
    @TableField("CJSJ")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime cjsj;

    @ApiModelProperty(value = "更新时间")
    @TableField("GXSJ")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime gxsj;


    @DictName(type = "SEX_TYPE", filedName = "xsxb", valSeparator = "|", nameSeparator = "+")
    @TableField(exist = false)
    private String xsxbDesc;

    @DictName(type = "ADDR_TYPE", filedName = "xsxb", valSeparator = "|", nameSeparator = "+")
    @TableField(exist = false)
    private String xsxbDesc1;

    @TableField(exist = false)
    private List<TAddrInfo> addrList;

    @TableField(exist = false)
    private TAddrInfo homeAddrBean;

    @TableField(exist = false)
    private TAddrInfo offcAddrBean;

}